<!--校内横向课题管理的页面，包含已完结，立项申请，结项申请的三个tab页面-->
<!DOCTYPE html>
<!--<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">-->
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="https://github.com/theborakompanioni/thymeleaf-extras-shiro"
      xmlns:padding="http://www.w3.org/1999/xhtml">

<head>
    <th:block th:include="include :: header('成果转化列表')"/>
    <th:block th:include="include :: datetimepicker-css"/>

</head>
<style>
    @media (min-width: 768px) {
        .col-sm-3 {
            width: 38% !important;
        }
    }

    .input-daterange {
        float: left;
    }

    /* 优化筛选框样式，确保间距一致 */
    .select-list ul {
        display: flex;
        flex-wrap: wrap;
        gap: 15px;
        padding: 0;
        margin: 0;
    }

    .select-list li {
        list-style: none;
        margin: 0;
        display: flex;
        align-items: center;
        flex: 0 0 calc(25% - 12px);
        min-width: 200px;
    }

    /* 第一行项目 - 占满整行 */
    .select-list li.first-row {
        flex: 0 0 100%;
    }

    /* 第一行中的子项 */
    .first-row-wrapper {
        display: flex;
        gap: 15px;
        width: 100%;
    }

    .first-row-item {
        flex: 0 0 calc(25% - 12px);
    }

    /* 第二行项目 */
    .select-list li.second-row.date-range-item,
    .select-list li.second-row.college-major-item {
        flex: 0 0 calc(50% - 8px);
    }

    .select-list li.button-item {
        flex: 0 0 100%;
        justify-content: flex-start;
        margin-top: 10px;
        gap: 15px;
    }

    .select-list li label {
        width: 80px;
        margin: 0 10px 0 0;
        text-align: right;
        line-height: 30px;
        white-space: nowrap;
    }

    /* 特殊处理日期范围选择标签 */
    .select-list li.date-range-item label.font-noraml {
        width: auto;
        margin: 0 10px 0 0;
        text-align: left;
    }

    .select-list li input.form-control,
    .select-list li select.form-control {
        flex: 1;
        width: 200px;
        height: 30px;
        border: 1px solid #ddd;
        border-radius: 4px;
        padding-left: 5px;
    }

    /* 学院专业选择框样式优化 */
    .college-major-item {
        flex: 0 0 calc(50% - 8px) !important;
    }

    .college-major-item #element2 {
        display: flex;
        align-items: center;
        width: 100%;
    }

    .college-major-item #element2 label {
        width: 80px;
        margin: 0 10px 0 0;
        text-align: right;
        line-height: 30px;
    }

    .college-major-item #element2 .row {
        flex: 1;
        display: flex;
        gap: 15px;
        margin: 0;
    }

    .college-major-item #element2 .col-sm-3 {
        flex: 1;
        padding: 0;
        max-width: 200px;
    }

    .college-major-item #element2 .col-sm-3 select.form-control {
        width: 100%;
        height: 30px;
        border: 1px solid #ddd;
        border-radius: 4px;
    }

    .select-list .input-daterange {
        display: flex;
        align-items: center;
        gap: 5px;
    }

    .select-list .input-daterange .form-control {
        width: 120px;
        flex: none;
    }

    .select-list .input-daterange .input-group-addon {
        width: auto;
        padding: 5px 10px;
        background-color: #f5f5f5;
        border: 1px solid #ddd;
        border-left: 0;
        border-right: 0;
        line-height: 20px;
    }

    /* 日期范围选择样式调整 */
    .select-list > ul > li.date-range-item {
        display: flex;
        align-items: center;
    }

    .select-list > ul > li.date-range-item label.font-noraml {
        margin: 0 10px 0 0;
        line-height: 30px;
        width: auto;
        text-align: left;
    }

    .track-rcol {
        width: 100%;
        max-width: 500px;
        margin: 20px auto;
        /*width: 450px;*/
        /*!*border: 1px solid #eee;*!*/
        /*margin: 20px auto;*/
        /*background: transparent;*/
        max-height: 400px;
        overflow-y: auto;
    }

    .btn-group-sm > .btn, .btn-sm {
        padding: 9px 10px;
        font-size: 12px;
        line-height: 1.5;
        border-radius: 3px;
    }

    .link-button {
        background: none;
        border: none;
        color: #2c99ff;
        cursor: pointer;
        font-size: inherit;
    }

    .del-link-button {
        background: none;
        border: none;
        color: #ff0000;
        cursor: pointer;
        font-size: inherit;
    }


    .modal-right {
        position: fixed;
        right: 0;
        margin: 0;
        height: 100%;
        display: flex;
        align-items: stretch;
    }

    .modal-right .modal-content {
        height: 100%;
        width: 70%;
        margin-left: auto;
    }

    .modal-right .but {
        position: absolute;
        right: 2%;
        bottom: 1.3%;
        background: red;
        color: white;
        border: none;
        border-radius: 4px;
    }

    .progress_inner {
        height: 80px;
        width: 100%;
        position: relative;
    }

    .progress_inner__step {
        width: 33.33%;
        font-size: 12px;
        padding: 0 5px;
        transition: all 0.4s;
        float: left;
        text-align: center;
        position: relative;
    }

    .progress_inner__step label {
        padding-top: 30px;
        display: block;
        position: relative;
        cursor: label;
    }

    .progress_inner__step:before {
        content: "1";
        width: 24px;
        height: 24px;
        color: #2196F3;
        background: white;
        line-height: 22px;
        border: 2px solid #2196F3;
        font-size: 12px;
        top: 0;
        border-radius: 50%;
        transition: all 0.4s;
        position: absolute;
        left: 0;
        right: 0;
        margin: auto;
        font-weight: bold;
        z-index: 11;
    }

    .progress_inner__step:nth-of-type(2):before {
        content: "2";
        color: #9E9E9E;
        border-color: #9E9E9E;
    }

    .progress_inner__step:nth-of-type(3):before {
        content: "3";
        color: #9E9E9E;
        border-color: #9E9E9E;
    }

    .progress_inner__step.completed:before {
        content: "✓";
        color: #4CAF50;
        border-color: #4CAF50;
        line-height: 22px;
        font-size: 14px;
    }

    .progress_inner__step.active:before {
        color: #2196F3;
        border-color: #2196F3;
        background: white;
    }

    .progress_inner__step.pending:before {
        color: #9E9E9E;
        border-color: #9E9E9E;
        background: white;
    }

    .progress_inner__bar {
        height: 3px;
        left: 16.665%;
        right: 16.665%;
        background: #E0E0E0;
        position: absolute;
        top: 12px;
        z-index: -1;
        border-radius: 3px;
        overflow: hidden;
    }

    .progress_inner__bar--progress {
        height: 100%;
        background: #4CAF50;
        width: 0;
        transition: width 0.6s ease;
    }


    .status-text {
        color: #9E9E9E;
        font-weight: normal;
        transition: all 0.4s;
        font-size: 12px;
    }

    .status-text.active {
        color: #2196F3;
        font-weight: bold;
    }

    .status-text.completed {
        color: #4CAF50;
        font-weight: bold;
    }

    .buttons {
        margin-top: 20px;
        text-align: center;
    }

    button {
        background: #2196F3;
        color: white;
        border: none;
        padding: 6px 12px;
        border-radius: 3px;
        margin: 0 8px;
        cursor: pointer;
        font-weight: bold;
        transition: all 0.3s;
        font-size: 12px;
    }

    button:hover {
        background: #1976D2;
    }

    button:last-child {
        background: #9E9E9E;
    }

    button:last-child:hover {
        background: #757575;
    }

    /* 新增的流程记录样式 */
    .timeline-title {
        font-weight: bold;
        font-size: 14px;
        color: #333;
        text-align: left;
        margin: 0 0 25px 20px;
        max-width: 500px;
        margin-left: auto;
        margin-right: auto;
        position: relative;
        padding-bottom: 15px;
    }

    .timeline-title::after {
        content: "";
        position: absolute;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 0.5px;
        /*background: linear-gradient(to right, #e0e0e0, #a0a0a0, #e0e0e0);*/
        background: linear-gradient(to right,
        rgba(224, 224, 224, 0.8),
        rgba(224, 224, 224, 0.8),
        rgba(224, 224, 224, 0.8)); /* 添加透明度使线条更柔和 */
        box-shadow: 0 0.5px 1px rgba(0, 0, 0, 0.07);
    }

    .track-rcol {
        width: 100%;
        max-width: 500px;
        margin: 20px auto;
        /*width: 450px;*/
        /*!*border: 1px solid #eee;*!*/
        /*margin: 20px auto;*/
        /*background: transparent;*/
    }

    .track-list {
        margin: 20px;
        padding-left: 5px;
        position: relative;
    }

    .track-list ul {
        padding-left: 0;
    }

    .track-list li {
        position: relative;
        padding: 5px 0 10px 25px;
        line-height: 1.4;
        border-left: 2px solid #d9d9d9;
        color: #666;
        list-style: none;
        /*text-align: left;*/
        transition: all 0.4s ease; /* 添加过渡效果 */
    }

    .track-list li.first {
        color: #666;
        padding-top: 0;
        /*border-left-color: #fff;*/
    }

    .track-list li .node-icon {
        position: absolute;
        left: -6px;
        top: 18px;
        width: 8px; /* 调圆点*/
        height: 8px;
        background: #C0C0C0;
        border-radius: 50%;
        transition: all 0.4s ease; /* 添加过渡效果 */
        border: 2px solid #E0E0E0;
        box-sizing: content-box;
    }

    .track-list li.first .node-icon {
        background: #C0C0C0; /* 天蓝色 */
        width: 8px;
        height: 8px;
        left: -8px;
    }

    .track-list li .time {
        display: block;
        margin-bottom: 3px;
        font-size: 11px;
        color: #888;
        transition: all 0.4s ease; /* 添加过渡效果 */
    }

    .track-list li .txt {
        display: block;
        font-size: 12px;
        transition: all 0.4s ease; /* 添加过渡效果 */
    }

    /* 悬停效果 */
    .track-list li:hover {
        color: #333;
    }

    .track-list li:hover .node-icon {
        transform: scale(1.3);
        background: #ed8088;
    }

    .track-list li:hover .time {
        color: #666;
    }

    /* 新增审核状态样式 */
    .approve-status {
        margin-top: 10px;
        text-align: center;
    }

    .approve-status label {
        margin: 0 10px;
        cursor: pointer;
    }

    .approve-status input {
        margin-right: 5px;
    }

    /* 响应式调整 */
    @media (max-width: 1200px) {
        .first-row-item {
            flex: 0 0 calc(33.333% - 10px);
        }

        .select-list li.second-row.date-range-item,
        .select-list li.second-row.college-major-item {
            flex: 0 0 calc(50% - 8px);
        }
    }

    @media (max-width: 992px) {
        .first-row-item {
            flex: 0 0 calc(50% - 8px);
        }

        .select-list li.second-row.date-range-item,
        .select-list li.second-row.college-major-item {
            flex: 0 0 calc(50% - 8px);
        }
    }

    @media (max-width: 768px) {
        .select-list li,
        .first-row-item,
        .select-list li.second-row.date-range-item,
        .select-list li.second-row.college-major-item {
            flex: 0 0 100%;
        }

        .select-list li.button-item {
            flex-direction: column;
            align-items: stretch;
        }

        .select-list li.button-item .btn {
            margin: 5px 0;
        }

        .first-row-wrapper {
            flex-direction: column;
        }
    }

</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeIn">

    <div class="row">

        <div class="tabs-container">
            <div class="tab-content">
                <div id="tab-0" class="tab-pane active">
                    <div class="panel-body">
                        <div class="container-div">
                            <div class="row">
                                <div class="col-sm-12 search-collapse">
                                    <form id="formId0">
                                        <div class="select-list">
                                            <ul>
                                                <li class="first-row">
                                                    <div class="first-row-wrapper">
                                                        <div class="first-row-item">
                                                            <label>项目类别：</label>
                                                            <select name="remark" class="form-control"
                                                                    th:with="type=${@dict.getType('sys_mold_name')}">
                                                                <option th:each="dict : ${type}"
                                                                        th:text="${dict.dictLabel}"
                                                                        th:value="${dict.dictValue}"></option>
                                                            </select>
                                                        </div>
                                                        <div class="first-row-item">
                                                            <label>数据状态：</label>
                                                            <select name="state" class="form-control"
                                                                    th:with="type=${@dict.getType('sys_module_item_state')}">
                                                                <option th:each="dict : ${type}"
                                                                        th:text="${dict.dictLabel}"
                                                                        th:value="${dict.dictValue}"></option>
                                                            </select>
                                                        </div>
                                                        <div class="first-row-item" shiro:hasPermission="sys_job_title">
                                                            <label>教师职称：</label>
                                                            <select name="job_title" class="form-control"
                                                                    th:with="type=${@dict.getType('sys_job_title')}">
                                                                <option th:each="dict : ${type}"
                                                                        th:text="${dict.dictLabel}"
                                                                        th:value="${dict.dictValue}"></option>
                                                            </select>
                                                        </div>
                                                        <div class="first-row-item">
                                                            <label>课题名称：</label>
                                                            <input type="text" class="input-sm form-control"
                                                                   id="topicName"
                                                                   name='topicName'/>
                                                        </div>
                                                    </div>
                                                </li>
                                                <li class="second-row date-range-item">
                                                    <label class="font-noraml">日期选择：</label>
                                                    <div class="input-group input-daterange">
                                                        <input type="text" class="input-sm form-control"
                                                               id="datetimepicker-startTime" placeholder="yyyy-MM-dd"/>
                                                        <span class="input-group-addon"
                                                              style="width: auto; padding: 0 10px;">到</span>
                                                        <input type="text" class="input-sm form-control"
                                                               id="datetimepicker-endTime" placeholder="yyyy-MM-dd"/>
                                                    </div>
                                                </li>
                                                <li class="second-row college-major-item"  shiro:hasPermission="sys_collage_filter">
                                                    <div id="element2" class="row">
                                                        <label>学院专业：</label>
                                                        <div class="col-sm-3">
                                                            <select class="first form-control m-b"></select>
                                                        </div>
                                                        <div class="col-sm-3">
                                                            <select class="second form-control m-b"></select>
                                                        </div>
                                                    </div>
                                                </li>
                                                <li class="button-item">
                                                    <a class="btn btn-primary btn-rounded btn-sm"
                                                       id="searchBtn"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                                    <a class="btn btn-warning btn-rounded btn-sm"
                                                       id="resetBtn"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                                </li>
                                            </ul>
                                        </div>
                                    </form>
                                </div>

                                <div class="btn-group-sm" id="toolbar0" role="group"
                                     style="display: flex; justify-content: space-between; align-items: center; width: 100%;">
                                    <a class="btn btn-warning" onclick=" exportExcel('bootstrap-table0')">
                                        <i class="fa fa-download"></i> 导出
                                    </a>
                                    <div
                                            style="display: flex; align-items: center; gap: 15px; background: #f8f9fa; padding: 6px 12px; border-radius: 4px;">
                                        <th:block th:replace="include :: status-circles"/>
                                    </div>
                                </div>
                                <div class="col-sm-12 select-table table-striped">
                                    <table id="bootstrap-table0"></table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<th:block th:include="include :: footer"/>
<th:block th:include="include :: jquery-cxselect-js"/>
<th:block th:include="include :: datetimepicker-js"/>
<script th:inline="javascript">
    $('#element2').cxSelect({
        selects: ['first', 'second'],
        required: true,
        jsonValue: 'v',
        data: [
            {
                'v': null, 'n': '学院', 's': [
                    {'v': null, 'n': '专业 '}
                ]
            },
            {
                "v": "1139",
                "n": "软件学院",
                "s": [
                    {'v': 'null', 'n': '空'},
                    {"v": "1174", "n": "软件工程教研室"},
                    {"v": "1179", "n": "计算机科学与技术教研室"},
                    {"v": "1191", "n": "数据科学与大数据技术教研室"},
                    {"v": "1207", "n": "智能科学与技术教研室"},
                    {"v": "1210", "n": "虚拟现实技术教研室"},
                    {"v": "1192", "n": "软件学院办公室"},
                    {"v": "1196", "n": "软件学院学生管理办公室"}
                ]
            },
            {
                "v": "1140",
                "n": "商学院",
                "s": [
                    {'v': 'null', 'n': '空'},
                    {"v": "1175", "n": "电子商务教研室"},
                    {"v": "1231", "n": "商学院办公室"},
                    {"v": "1228", "n": "商学院学生管理办公室"},
                    {"v": "1215", "n": "物流管理教研室"},
                    {"v": "1194", "n": "网络与新媒体教研室"},
                    {"v": "1181", "n": "财务管理教研室"}
                ]
            },
            {
                "v": "1145",
                "n": "艺术设计学院",
                "s": [
                    {'v': 'null', 'n': '空'},
                    {"v": "1188", "n": "环境设计教研室"},
                    {"v": "1211", "n": "艺术设计学院学生管理办公室"},
                    {"v": "1182", "n": "视觉传达设计教研室"}
                ]
            },
            {
                "v": "1147", "n": "电子工程学院",
                "s": [
                    {'v': 'null', 'n': '空'},
                    {"v": "1187", "n": "人工智能教研室"},
                    {"v": "1184", "n": "电子信息工程教研室"},
                    {"v": "1222", "n": "电子工程学院学生管理办公室"},
                    {"v": "1223", "n": "自动化教研室"},
                    {"v": "1224", "n": "工程训练中心"},
                    {"v": "1225", "n": "物理教研室"},
                    {"v": "1233", "n": "资料室"},
                    {"v": "1235", "n": "电子工程办公室"}
                ]
            }
        ]
    });
    var datas = [[${@dict.getType('sys_intraschpro_tasks')}]];
    var prefix = ctx + "StatsQuery";
    var hasSearched = false; // 添加搜索状态标志  初始菜单不加载 ,点击搜索之后才会显示
    var paiMingDatas = [[${@dict.getType('sys_jiaocairuanzhu_fzr')}]];
    var fenleiDatas = [[${@dict.getType('sys_zhuanli_fenlei')}]];
    var dengjiDatas = [[${@dict.getType('sys_reward_dengji')}]];
    var prefixZX = ctx + "system/apply_vertical";
    var prefixHX = ctx + "system/apply";
    var prefixCGZH = ctx + "IntraSchPro";
    var prefixLW = ctx + "system/paper";
    var prefixJCZZ = ctx + "system/jiaocairuanzhu";
    var prefixZLRZ = ctx + "system/zhuanliruanzhu";
    var prefixJL = ctx + "system/reward";
    var prefixJZBG = ctx + "system/report";

    // 定义不同项目类别对应的表格列配置
    var tableColumnsConfig = {
        // 成果转化
        '3': [
            {
                field: 'number',
                title: '序号',
                width: 5,
                align: 'center',
                switchable: false,
                formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }
            },
            {
                field: 'id',
                title: 'id',
                visible: false
            },
            {
                field: 'yname',
                align: 'center',
                title: '学院'
            },
            {
                field: 'dname',
                align: 'center',
                title: '专业'
            },
            {
                field: 'userName',
                align: 'center',
                title: '申请人'
            },
            {
                field: 'topName',
                align: 'center',
                title: '课题名称'
            },
            {
                field: 'signingData',
                align: 'center',
                title: '签订日期'
            },
            {
                field: 'amount',
                align: 'center',
                title: '项目金额'
            },
            {
                title: '操作',
                align: 'center',
                formatter: function (value, row, index) {
                    var actions = [];
                    actions.push('<a class="link-button" href="javascript:void(0)" onclick=\'OpenDetailTab("' + row.id + '","CGZH")\'>查看</a> ');
                    return actions.join('');
                }
            }
        ],
        // 纵向课题

        '1': [
            {
                field: 'number',
                title: '序号',
                width: 5,
                align: 'center',
                switchable: false,
                formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }
            },
            {
                field: 'id',
                title: 'id',
                visible: false
            },
            {
                field: 'yname',
                align: 'center',
                title: '学院'
            },
            {
                field: 'dname',
                align: 'center',
                title: '专业'
            },
            {
                field: 'userName',
                align: 'center',
                title: '申请人'
            },
            {
                field: 'topName',
                align: 'center',
                title: '课题名称'
            },
            {
                field: 'signingData',
                align: 'center',
                title: '签订日期'
            },
            {
                field: 'amount',
                align: 'center',
                title: '项目金额'
            },
            {
                title: '操作',
                align: 'center',
                formatter: function (value, row, index) {
                    var actions = [];
                    actions.push('<a class="link-button" href="javascript:void(0)" onclick=\'OpenDetailTab("' + row.id + '","ZX")\'>查看</a> ');
                    return actions.join('');
                }
            }
        ],
        // 横向课题
        '2': [
            {
                field: 'number',
                title: '序号',
                width: 5,
                align: 'center',
                switchable: false,
                formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }
            },
            {
                field: 'id',
                title: 'id',
                visible: false
            },
            {
                field: 'dname',
                align: 'center',
                title: '专业'
            },
            {
                field: 'userName',
                align: 'center',
                title: '申请人'
            },
            {
                field: 'topName',
                align: 'center',
                title: '课题名称'
            },
            {
                field: 'amount',
                align: 'center',
                title: '金额'
            },
            // {
            //     field: 'responsibilityTier',
            //     title: '责任层级',
            //     align: 'center',
            //     formatter: function (value, row, index) {
            //         return row.firstPersonId == row.uid ? '第一负责人' : row.secondPersonId == row.uid ? '第二负责人' : row.thirdPersonId == row.uid ? "第三负责人" : row.fourthPersonId == row.uid ? "第四负责人" : "不是负责人";
            //     }
            // },
            // {
            //     field: 'responsibilityTier',
            //     title: '积分',
            //     align: 'center',
            //     formatter: function (value, row, index) {
            //         if (row.state == 6) {
            //             return row.firstPersonId == row.uid ? row.firstPoints : row.secondPersonId == row.uid ? row.secondPoints : row.thirdPersonId == row.uid ? row.thirdPoints : row.fourthPersonId == row.uid ? row.forthPoints : 0;
            //         } else {
            //             return 0;
            //         }
            //     }
            // },
            {
                title: '操作',
                align: 'center',
                formatter: function (value, row, index) {
                    var actions = [];
                    actions.push('<a class="link-button" href="javascript:void(0)" onclick=\'OpenDetailTab("' + row.id + '","HX")\'>查看</a> ');
                    return actions.join('');

                    return actions.join('');
                }
            }
        ],
        //论文
        '4': [
            {
                field: 'number',
                title: '序号',
                width: 5,
                align: 'center',
                switchable: false,
                formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }
            },
            {
                field: 'id',
                title: 'id',
                visible: false
            },
            {
                field: 'college',
                align: 'center',
                title: '学院'
            },
            {
                field: 'college',
                align: 'center',
                title: '专业'
            },
            {
                field: 'researchRoom',
                align: 'center',
                title: '申请人'
            },
            {
                field: 'paperTitle',
                title: '论文名称',
                align: 'center',
                formatter: function(value, row, index) {
                    if (!value) return ''; // 处理空值情况

                    // 如果长度超过指定字符数（例如20个字符），则截取并添加省略号
                    const maxLength = 20;
                    if (value.length > maxLength) {
                        return '<span title="' + value + '">' + value.substring(0, maxLength) + '...</span>';
                    }
                    return value;
                }
            },
            // {
            //     field: 'responsibilityTier',
            //     title: '责任层级',
            //     align: 'center',
            //     formatter: function (value, row, index) {
            //         return row.firstPersonId == row.uid ? '一作' : row.secondPersonId == row.uid ? '二作' : row.thirdPersonId == row.uid ? "三作" : row.fourthPersonId == row.uid ? "四作" : "不是作者";
            //     }
            // },
            // {
            //     field: 'responsibilityTier',
            //     title: '积分',
            //     align: 'center',
            //     formatter: function (value, row, index) {
            //         if (row.state == 6) {
            //             return row.firstPersonId == row.uid ? row.firstAuthorScore : row.secondPersonId == row.uid ? row.secondAuthorScore : row.thirdPersonId == row.uid ? row.thirdAuthorScore : row.fourthPersonId == row.uid ? row.fourthAuthorScore : "不是作者";
            //         } else {
            //             return 0;
            //         }
            //     }
            // },
            {
                title: '操作',
                align: 'center',
                formatter: function (value, row, index) {
                    //console.log('论文:row = ',row);
                    var actions = [];
                    actions.push('<a class="link-button" href="javascript:void(0)" onclick=\'OpenDetailTab("' + row.id + '","LW")\'>查看</a> ');

                    return actions.join('');
                }
            }
        ],
        //教材专著
        '5': [
            {
                field: 'number',
                title: '序号',
                width: 5,
                align: 'center',
                switchable: false,
                formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }
            },
            {
                field: 'id',
                title: 'id',
                visible: false
            },
            {
                field: 'xueyuan',
                title: '学院'
            },
            {
                field: 'jiaoyanshi',
                align: 'center',
                title: '专业'
            },

            {
                field: 'xingming',
                align: 'center',
                title: '申请人'
            },
            {
                field: 'chubanshijian',
                title: '出版时间'
            },
            {
                field: 'mingcheng',
                align: 'center',
                title: '教材软著名称'
            },
            {
                field: 'paiming',
                title: '负责人排名',
                formatter: function (value, row, index) {
                    return $.table.selectDictLabel(paiMingDatas, value);
                }
            },
            // {
            //     field: 'responsibilityTier',
            //     title: '积分',
            //     align: 'center',
            //     formatter: function (value, row, index) {
            //         if (row.state == 6) {
            //             return row.firstPersonId == row.uid ? row.firstAuthorScore : row.secondPersonId == row.uid ? row.secondAuthorScore : row.thirdPersonId == row.uid ? row.thirdAuthorScore : row.fourthPersonId == row.uid ? row.fourthAuthorScore : "不是作者";
            //         } else {
            //             return 0;
            //         }
            //     }
            // },
            {
                title: '操作',
                align: 'center',
                formatter: function (value, row, index) {
                    //console.log('教材专著:row = ',row);
                    var actions = [];
                    actions.push('<a class="link-button" href="javascript:void(0)" onclick=\'OpenDetailTab("' + row.id + '","JCZZ")\'>查看</a> ');

                    return actions.join('');
                }
            }
        ],
        //专利软著
        '6': [
            {
                field: 'number',
                title: '序号',
                width: 5,
                align: 'center',
                switchable: false,
                formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }
            },
            {
                field: 'id',
                title: 'id',
                visible: false
            },
            {
                field: 'xueyuan',
                title: '学院'
            },
            {
                field: 'jiaoyanshi',
                title: '专业'
            },

            {
                field: 'xingming',
                title: '姓名'
            },
            {
                field: 'mingcheng',
                title: '专利名称'
            },
            // {
            //     field: 'huopishijain',
            //     title: '获批时间'
            // },
            {
                field: 'fenlei',
                title: '分类',
                formatter: function (value, row, index) {
                    return $.table.selectDictLabel(fenleiDatas, value);
                }
            },
            // {
            //     field: 'jifen',
            //     title: '积分'
            // },
            {
                field: 'paiming',
                title: '负责人排名',
                formatter: function (value, row, index) {
                    return $.table.selectDictLabel(paiMingDatas, value);
                }
            },

            {
                title: '操作',
                align: 'center',
                formatter: function (value, row, index) {
                    //console.log('专利软著:row = ',row);
                    var actions = [];
                    actions.push('<a class="link-button" href="javascript:void(0)" onclick=\'OpenDetailTab("' + row.id + '","ZLRZ")\'>查看</a> ');

                    return actions.join('');
                }
            }
        ],
        //奖励
        '7': [
            {
                field: 'number',
                title: '序号',
                width: 5,
                align: 'center',
                switchable: false,
                formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }
            },
            {
                field: 'id',
                title: 'id',
                visible: false
            },
            {
                field: 'yname',
                align: 'center',
                title: '学院'
            },

            {
                field: 'dname',
                align: 'center',
                title: '专业'
            },
            {
                field: 'userName',
                title: '申请人'
            },
            {
                field: 'mingcheng',
                title: '荣誉名称'
            },
            {
                field: 'rewardTime',
                title: '获批时间'
            },
            {
                field: 'fenlei',
                title: '分类',
                formatter: function (value, row, index) {
                    return $.table.selectDictLabel(fenleiDatas, value);
                }
            },
            {
                field: 'rewardDengji',
                title: '等级',
                formatter: function (value, row, index) {
                    return $.table.selectDictLabel(dengjiDatas, value);
                }
            },
            {
                field: 'rewardPaiming',
                title: '排名',
                formatter: function (value, row, index) {
                    return $.table.selectDictLabel(paiMingDatas, value);
                }
            },
            // {
            //     field: 'jifen',
            //     title: '积分'
            // },

            {
                title: '操作',
                align: 'center',
                formatter: function (value, row, index) {
                    //console.log('奖励:row = ',row);
                    var actions = [];
                    actions.push('<a class="link-button" href="javascript:void(0)" onclick=\'OpenDetailTab("' + row.id + '","JL")\'>查看</a> ');

                    return actions.join('');
                }
            }
        ],
        //讲座报告
        '8': [
            {
                field: 'number',
                title: '序号',
                width: 5,
                align: 'center',
                switchable: false,
                formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }
            },
            {
                field: 'id',
                title: 'jobId',
                visible: false
            },
            {
                field: 'xueyuan',
                align: 'center',
                title: '学院'
            },

            {
                field: 'keyanshi',
                align: 'center',
                title: '专业'
            },
            {
                field: 'teacherName',
                align: 'center',
                title: '申请人'
            },
            {
                field: 'reportTheme',
                align: 'center',
                title: '主题'
            },
            {
                field: 'reportSubject',
                align: 'center',
                title: '题目'
            },
            // {
            //     field: 'reportTime',
            //     align: 'center',
            //     title: '开始时间'
            // },
            // {
            //     field: 'reportEndTime',
            //     align: 'center',
            //     title: '结束时间'
            // },

            // {
            //     field: 'reportKeyanfen',
            //     title: '积分'
            // },

            {
                title: '操作',
                align: 'center',
                formatter: function (value, row, index) {
                    //console.log('讲座报告:row = ',row);
                    var actions = [];
                    actions.push('<a class="link-button" href="javascript:void(0)" onclick=\'OpenDetailTab("' + row.id + '","JZBG")\'>查看</a> ');

                    return actions.join('');
                }
            }
        ]
    };
    // 搜索,初始化
    $(function () {
        // 绑定搜索按钮点击事件
        $('#searchBtn').on('click', function () {
            var remark = $("select[name='remark']").val(); // 项目类别
            var state = $("select[name='state']").val(); // 项目类别
            var startTime = $("#datetimepicker-startTime").val(); // 开始时间
            var endTime = $("#datetimepicker-endTime").val(); // 结束时间
            var college = $(".first").val(); // 学院
            var major = $(".second").val(); // 专业
            var jobTitle = $("select[name='job_title']").val(); // 职称
            var topicName = $("#topicName").val(); // 课题名称

            // 构造查询参数对象
            var params = {
                remark: remark,
                state: state,
                startTime: startTime,
                endTime: endTime,
                college: college,
                major: major,
                jobTitle: jobTitle,
                topicName: topicName
            };
            console.log("搜索参数:", params)
            // 设置搜索状态为true
            hasSearched = true;

            // 根据项目类别获取对应的表格列配置
            var selectedRemark = remark || 'default';
            var columns = tableColumnsConfig[selectedRemark] || tableColumnsConfig['default'];

            // 更新表格配置，显示表头并设置列
            $('#bootstrap-table0').bootstrapTable('refreshOptions', {
                showHeader: true,
                columns: columns,
                queryParams: function (p) {
                    return $.extend(p, params);
                }
            });
            //$('#bootstrap-table0').bootstrapTable('refresh');
        });

        // 绑定重置按钮点击事件
        $('#resetBtn').on('click', function () {
            // 重置搜索状态
            hasSearched = false;
            // 清空表单
            $('#formId0')[0].reset();
            // 清空表格数据，隐藏表头
            $('#bootstrap-table0').bootstrapTable('refreshOptions', {
                showHeader: false,
                columns: [],
                queryParams: function (p) {
                    return {
                        pageNum: 1,
                        pageSize: 10,
                        orderByColumn: '',
                        isAsc: 'asc',
                        remark: '',
                        state: '',
                        startTime: '',
                        endTime: '',
                        college: '',
                        major: '',
                        jobtitle: 'id',
                        topicName: '',
                        noData: true
                    };
                }
            });
            $('#bootstrap-table0').bootstrapTable('refresh');
        });
    });
    // 根据筛选条件
    // 初始化表格
    $(function () {
        // tab-0
        var options0 = {
            id: "bootstrap-table0",
            toolbar: "toolbar0",
            url: prefix + "/list",
            search: prefix + "/list",
            rowStyle: rowStyle0,
            modalName: "统计查询",
            sortOrder: "asc",
            showHeader: false, // 初始不显示表头
            columns: [], // 初始为空列
            exportUrl: prefix + "/export",
            queryParams: function (params) {
                // 如果还没有搜索过，返回空数据请求
                if (!hasSearched) {
                    return {
                        pageNum: 1,
                        pageSize: 10,
                        orderByColumn: '',
                        isAsc: 'asc',
                        remark: '',
                        state: '',
                        startTime: '',
                        endTime: '',
                        college: '',
                        major: '',
                        jobTitle: '',
                        topicName: '',
                        noData: true // 添加标志告诉后端不返回数据
                    };
                }

                var searchParams = {
                    pageNum: params.pageNum,
                    pageSize: params.pageSize,
                    orderByColumn: params.orderByColumn,
                    isAsc: params.isAsc,
                    remark: params.remark || '',
                    state: params.state || '',
                    startTime: params.startTime || '',
                    endTime: params.endTime || '',
                    college: params.college || '',
                    major: params.major || '',
                    jobTitle: params.jobTitle || '',
                    topicName: params.topicName || ''
                };
                return searchParams;
            }
        };
        $.table.init(options0);
    });

    //设置不同模块的状态颜色
    function rowStyle0(row, index) {
        // 添加对 row 对象的检查
        if (!row || !row.state) {
            return {};
        }
        var remark = $("select[name='remark']").val(); // 项目类别
        //console.log("row = ", row)
        //console.log("remark = ", remark=="1",remark)
        //纵向课题
        if (remark == "1") {
            if (["66", "6"].includes(row.state)) {
                //console.log("row.state is 6", row.state)
                // 完结 绿色
                return {
                    css: {"color": '#67c23a'}

                };
            } else if (["3", "5", "7", "33", "55", "77", "99"].includes(row.state)) {
                // 草稿 黄色
                return {
                    css: {"color": '#c78045'}

                };
            } else if (["1", "2", "11", "4", "22", "44"].includes(row.state)) {
                // 审核中 蓝色
                return {
                    css: {"color": '#2c99ff'}

                };
            }
        }
        //横向课题
        else if (remark == "2") {
            if (["6", "4"].includes(row.state)) {
                //console.log("row.state is 6", row.state)
                // 完结 绿色
                return {
                    css: {"color": '#67c23a'}

                };
            } else if (["3", "5", "9", "10", "22", "44", "99"].includes(row.state)) {
                // 草稿 黄色
                return {
                    css: {"color": '#c78045'}

                };
            } else if (["1", "2", "11", "7", "8", "33"].includes(row.state)) {
                // 审核中 蓝色
                return {
                    css: {"color": '#2c99ff'}

                };
            }
        }
        //成果转化
        else if (remark == "3") {
            if (["6", "4"].includes(row.state)) {
                //console.log("row.state is 6", row.state)
                // 完结 绿色
                return {
                    css: {"color": '#67c23a'}

                };
            } else if (["15", "4", "16"].includes(row.state)) {
                // 草稿 黄色
                return {
                    css: {"color": '#c78045'}

                };
            } else if (["1", "2", "11", "7", "8", "13"].includes(row.state)) {
                // 审核中 蓝色
                return {
                    css: {"color": '#2c99ff'}

                };
            } else if (["3", "5", "12", "9", "10", "14"].includes(row.state)) {
                // 被驳回
                return {
                    // css: {"color": '#ff0000'}
                    css: {"color": '#c78045'}
                };
            }
        }
        //论文
        else if (remark == "4") {
            if (["8"].includes(row.state)) {
                //console.log("row.state is 6", row.state)
                // 完结 绿色
                return {
                    css: {"color": '#67c23a'}

                };
            } else if (["3", "5", "7", "9", "10", "22", "44", "99"].includes(row.state)) {
                // 草稿 黄色
                return {
                    css: {"color": '#c78045'}

                };
            } else if (["1", "2", "11", "4", "6", "13"].includes(row.state)) {
                // 审核中 蓝色
                return {
                    css: {"color": '#2c99ff'}

                };
            }
        }
        //教材专著
        else if (remark == "5") {
            if (["6"].includes(row.state)) {
                //console.log("row.state is 6", row.state)
                // 完结 绿色
                return {
                    css: {"color": '#67c23a'}

                };
            } else if (["3", "5", "7", "0"].includes(row.state)) {
                // 草稿 黄色
                return {
                    css: {"color": '#c78045'}

                };
            } else if (["1", "2", "4"].includes(row.state)) {
                // 审核中 蓝色
                return {
                    css: {"color": '#2c99ff'}

                };
            }
        }
        //专利软著
        else if (remark == "6") {
            if (["6"].includes(row.state)) {
                //console.log("row.state is 6", row.state)
                // 完结 绿色
                return {
                    css: {"color": '#67c23a'}

                };
            } else if (["3", "5", "7", "0"].includes(row.state)) {
                // 草稿 黄色
                return {
                    css: {"color": '#c78045'}

                };
            } else if (["1", "2", "4"].includes(row.state)) {
                // 审核中 蓝色
                return {
                    css: {"color": '#2c99ff'}

                };
            }
        }
        //奖励
        else if (remark == "7") {
            if (["6"].includes(row.state)) {
                //console.log("row.state is 6", row.state)
                // 完结 绿色
                return {
                    css: {"color": '#67c23a'}

                };
            } else if (["3", "5", "7", "11"].includes(row.state)) {
                // 草稿 黄色
                return {
                    css: {"color": '#c78045'}

                };
            } else if (["1", "2", "4"].includes(row.state)) {
                // 审核中 蓝色
                return {
                    css: {"color": '#2c99ff'}

                };
            }
        }
        //讲座报告
        else if (remark == "8") {
            if (["4"].includes(row.state)) {
                //console.log("row.state is 6", row.state)
                // 完结 绿色
                return {
                    css: {"color": '#67c23a'}

                };
            } else if (["3", "5", "7", "0"].includes(row.state)) {
                // 草稿 黄色
                return {
                    css: {"color": '#c78045'}

                };
            } else if (["1", "2", "6"].includes(row.state)) {
                // 审核中 蓝色
                return {
                    css: {"color": '#2c99ff'}

                };
            }
        }
        return {};
    }


    // 规则
    $("#datetimepicker-startTime").datetimepicker({
        format: 'yyyy-mm-dd',
        minView: "month",
        todayBtn: true,
        autoclose: true,
        endDate: new Date(),
    }).on('changeDate', function (event) {
        event.preventDefault();
        event.stopPropagation();
        var startTime = event.date;
        $('#datetimepicker-endTime').datetimepicker('setStartDate', startTime);
    });

    $("#datetimepicker-endTime").datetimepicker({
        format: 'yyyy-mm-dd',
        minView: "month",
        todayBtn: true,
        autoclose: true,
        endDate: new Date(),
    }).on('changeDate', function (event) {
        event.preventDefault();
        event.stopPropagation();
        var endTime = event.date;
        $("#datetimepicker-startTime").datetimepicker('setEndDate', endTime);
    });
    var startDate = laydate.render({
        elem: '#laydate-startTime',
        max: $('#laydate-endTime').val(),
        theme: 'molv',
        trigger: 'click',
        done: function (value, date) {
            // 结束时间大于开始时间
            if (value !== '') {
                endDate.config.min.year = date.year;
                endDate.config.min.month = date.month - 1;
                endDate.config.min.date = date.date;
            } else {
                endDate.config.min.year = '';
                endDate.config.min.month = '';
                endDate.config.min.date = '';
            }
        }
    });
    var endDate = laydate.render({
        elem: '#laydate-endTime',
        min: $('#laydate-startTime').val(),
        theme: 'molv',
        trigger: 'click',
        done: function (value, date) {
            // 开始时间小于结束时间
            if (value !== '') {
                startDate.config.max.year = date.year;
                startDate.config.max.month = date.month - 1;
                startDate.config.max.date = date.date;
            } else {
                startDate.config.max.year = '';
                startDate.config.max.month = '';
                startDate.config.max.date = '';
            }
        }
    });

    function OpenDetailTab(id, remark) {
        // 纵向
        if (remark == "ZX") {
            var url = prefixZX + "/overView/" + id + '/ZX';
            $.modal.openTab("查看纵向详情", url);
        }
        // 横向
        else if (remark == "HX") {
            var url = prefixHX + "/overView/" + id + '/HX';
            $.modal.openTab("查看横向详情", url);
        }
        // 成果转化
        else if (remark == "CGZH") {
            var url = prefixCGZH + "/detail/" + id + '/CGZH';
            $.modal.openTab("查看成果转化详情", url);
        }
        // 论文
        else if (remark == "LW") {
            var url = prefixLW + "/detail/" + id + '/LW';
            $.modal.openTab("查看论文详情", url);
        }
        // 教材专著
        else if (remark == "JCZZ") {
            var url = prefixJCZZ + "/detail/" + id + '/JCZZ';
            $.modal.openTab("查看教材专著详情", url);
        }
        // 专利软著
        else if (remark == "ZLRZ") {
            var url = prefixZLRZ + "/detail/" + id + '/ZLRZ';
            $.modal.openTab("查看专利软著详情", url);
        }
        // 奖励
        else if (remark == "JL") {
            var url = prefixJL + "/detail/" + id + '/JL';
            $.modal.openTab("查看奖励详情", url);
        }
        // 讲座报告
        else if (remark == "JZBG") {
            var url = prefixJZBG + "/detail/" + id + '/JZBG';
            $.modal.openTab("查看讲座报告详情", url);
        }

    };

    // 导出数据
    function exportExcel() {
        $.modal.confirm("确定导出所有" + table.options.modalName + "吗？", function () {
            // 创建参数对象而不是数组
            var exportParams = {};
            var remark = $("select[name='remark']").val();
            var state = $("select[name='state']").val();
            var startTime = $("#datetimepicker-startTime").val();
            var endTime = $("#datetimepicker-endTime").val();
            var college = $(".first").val();
            var major = $(".second").val();
            var jobTitle = $("select[name='job_title']").val();
            var topicName = $("#topicName").val();

            // 设置参数，state使用dictLabel
            exportParams.remark = remark || '';
            exportParams.state = state || ''; // 使用dictLabel而不是dictValue
            exportParams.startTime = startTime || '';
            exportParams.endTime = endTime || '';
            exportParams.college = college || '';
            exportParams.major = major || '';
            exportParams.jobTitle = jobTitle || '';
            exportParams.topicName = topicName || '';

            // 添加表格当前的查询参数
            var tableOptions = $("#" + table.options.id).bootstrapTable('getOptions');
            if (tableOptions && tableOptions.queryParams) {
                var queryParams = tableOptions.queryParams({
                    pageNum: 1,
                    pageSize: 99999999, // 导出所有数据
                    orderByColumn: tableOptions.sortName || '',
                    isAsc: tableOptions.sortOrder || 'asc'
                });

                // 合并查询参数
                $.extend(exportParams, queryParams);
            }

            // 添加排序参数
            if (tableOptions) {
                exportParams.orderByColumn = tableOptions.sortName || '';
                exportParams.isAsc = tableOptions.sortOrder || 'asc';
            }

            // 检查是否有导出URL
            if (!table.options.exportUrl) {
                $.modal.alertError("未配置导出URL");
                return;
            }

            $.modal.loading("正在导出数据，请稍候...");
            $.post(table.options.exportUrl, exportParams, function (result) {
                if (result.code === web_status.SUCCESS) {
                    window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                } else if (result.code === web_status.WARNING) {
                    $.modal.alertWarning(result.msg);
                } else {
                    $.modal.alertError(result.msg);
                }
                $.modal.closeLoading();
            }).fail(function (jqXHR, textStatus, errorThrown) {
                $.modal.alertError("导出请求失败: " + textStatus);
                $.modal.closeLoading();
            });
        });
    }


</script>
</body>
</html>